<?php

namespace app\services\websocket;

use think\swoole\Websocket;

class Event
{
    public function handle($event)
    {
        echo '接收到事件,';
        dump($event);
        $func = $event->type;
        try {


            Util::boardcast($event->data);

            return $this->$func($event);
        }catch (\Throwable  $e){
            dump($e->getMessage());
        }

        echo "websocket Event". PHP_EOL;
        return '';
    }

    public function test($event)
    {
        $msg = json_encode($event->data,256);
        dump("test方法执行了" .$msg);

        return $msg;
//        $this->websocket->emit('callback', $msg);
    }

}